﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		PageUrlBuilder.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 // 
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using Dexter.CallContext;
using Dexter.DataTransferObject;
using Dexter.Domain.Model;
using Dexter.Logger.Contracts;

namespace Dexter.Services.Implementation {
	/// <summary>
	/// 	The implementation of <see cref = "IPageUrlBuilder" />.
	/// </summary>
	public class PageUrlBuilder : UrlBuilderBase, IPageUrlBuilder {
		readonly ILogger logger;

		public PageUrlBuilder ( ILogger logger , IDexterContext context , IConfigurationService configurationService ) : base ( logger , context , configurationService ) {
			this.logger = logger;
		}

		/// <summary>
		/// 	Return the detail url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/
		/// </example>
		public virtual string Detail ( Page item ) {
			return ToCaseConfiguration ( new Uri ( HomePage, item.Slug ) );
		}

		/// <summary>
		/// 	Return the detail url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/
		/// </example>
		public virtual string Detail(PageDto item)
		{
			return ToCaseConfiguration(new Uri(HomePage, item.Slug));
		}

		/// <summary>
		/// Return the detail url of the specified <see cref="PageStructure"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/
		/// </example>
		public virtual string Detail ( PageStructure item ) {
			return ToCaseConfiguration ( new Uri ( HomePage, item.Slug ) );
		}

		/// <summary>
		/// Return the detail url of the specified <see cref="PageStructure"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/
		/// </example>
		public virtual string Detail ( PageStructureDto item ) {
			return ToCaseConfiguration ( new Uri ( HomePage, item.Slug ) );
		}

		/// <summary>
		/// 	Return the print url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/Print
		/// </example>
		public virtual string Print ( Page item ) {
			logger.Warn ( "Method not implemented!" );
			return null;
		}

		/// <summary>
		/// 	Return the feed url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/Feed
		/// </example>
		public virtual string Feed ( Page item ) {
			logger.Warn ( "Method not implemented!" );
			return null;
		}

		/// <summary>
		/// 	Return the statistic url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/My-Page/Statistics
		/// </example>
		public virtual string Statistics ( Page item ) {
			logger.Warn ( "Method not implemented!" );
			return null;
		}

		/// <summary>
		/// 	Return the edit url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Page/Edit/10/
		/// </example>
		public virtual string Edit ( Page item ) {
			var segments = string.Format ( "Admin/Page/Editor/{0}/" , item.Id );

			return ToCaseConfiguration ( new Uri ( HomePage, segments ) );
		}

		/// <summary>
		/// 	Return the edit url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Page/Edit/10/
		/// </example>
		public virtual string Edit(PageDto item)
		{
			var segments = string.Format("Admin/Page/Editor/{0}/", item.Id);

			return ToCaseConfiguration(new Uri(HomePage, segments));
		}

		/// <summary>
		/// 	Return the delete url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Page/Edit/10/
		/// </example>
		public virtual string Delete ( Page item ) {
			string dt = string.Format ( "Admin/Page/ConfirmDelete/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// 	Return the delete url of the specified <see cref = "Page" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Page/Edit/10/
		/// </example>
		public virtual string Delete(PageDto item)
		{
			string dt = string.Format("Admin/Page/ConfirmDelete/{0}/", item.Id);
			return ToCaseConfiguration(new Uri(HomePage, dt));
		}
	}
}
